package com.example.nfc.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;

import com.example.nfc.R;
import com.example.nfc.base.BaseNfcActivity;
import com.example.nfc.server.Const;
import com.example.nfc.server.network.http.HttpException;
import com.example.nfc.server.request.JeDoSaveRequest;
import com.example.nfc.server.response.saveRespone.JeDoSaveRespone;
import com.example.nfc.server.utils.SharedPreferencesUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RukuActivity extends BaseNfcActivity {

    int index = 0 ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ruku);
        ButterKnife.bind(this);
        index = getData(Const.LAST_INDEX,10);
    }

    @Bind(R.id.mc)
    EditText mc;
    @OnClick(R.id.ruku)
    public void rukuClick(){
        if(TextUtils.isEmpty(mc.getText().toString())){
            shortToast("请输入名称！");
            return;
        }
        jeDoSaveRequest = new JeDoSaveRequest();
        jeDoSaveRequest.setUploadableFields("");
        jeDoSaveRequest.setINFO_MC(mc.getText().toString());
        jeDoSaveRequest.setSY_CREATEUSERNAME("%E7%B3%BB%E7%BB%9F%E6%BC%94%E7%A4%BA%E8%B4%A6%E5%8F%B7");
//        jeDoSaveRequest.setFun
//        private String uploadableFields;//
//        private String INFO_MC;//%E6%B5%8B%E8%AF%95
//        private String INFO_ID;//
//        private String SY_CREATEUSERNAME;//%E7%B3%BB%E7%BB%9F%E6%BC%94%E7%A4%BA%E8%B4%A6%E5%8F%B7
//        private String funcEdit;//true
//        private String SY_ORDERINDEX;//0
//        private String jeFileType;//PROJECT
//        private String funcType;//func
//        private String SY_CREATEORGID;//5WJznuFlur3pMhcDRGf
//        private String codeGenFieldInfo;//%5B%5D
//        private String SY_STATUS;//
//        private String SY_CREATEUSERID;//HSKWsldAiXoorKxBoBv
//        private String INFO_FRID;//2323423
//        private String filePath;//
//        private String funcCode;//INFO
//        private String SY_AUDFLAG;//NOSTATUS
//        private String SY_PIID;//
//        private String tableCode;//INFO
//        private String INFO_ZT;//xz
//        private String SY_PDID;//
//        private String INFO_GPS;//2232
//        private String viewConfigInfo;//
//        private String SY_CREATEORG;//ADMINISTRATOR
//        private String SY_CREATEUSER;//13417880000
//        private String SY_CREATEORGNAME;//%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E9%83%A8
//        private String SY_CREATETIME;//2021-05-20%2013%3A40%3A39
//        private String batchFilesFields;//
//        private String viewTableCode;//
//        private String SY_JTGSMC;//%E5%95%86%E5%9F%8E%E6%B5%8B%E8%AF%95
//        private String SY_JTGSID;//zD9Eqjf2iWWnryJeWB1
    }

    private static final int SAVE = 1023;
    private JeDoSaveRequest jeDoSaveRequest;
    @Override
    public Object doInBackground(int requestCode, String parameter) throws HttpException {
        switch (requestCode){
            case SAVE:
                return action.saveDataRequest(jeDoSaveRequest);
        }
        return super.doInBackground(requestCode, parameter);
    }

    @Override
    public void onSuccess(int requestCode, Object result) {
        super.onSuccess(requestCode, result);
        switch (requestCode){
            case SAVE:
                JeDoSaveRespone respone = (JeDoSaveRespone)result;
                if("1000".equals(respone.getCode())){
                    shortToast("入库成功!");
                }else{
                    shortToast("入库失败!");
                }
                break;
        }
    }

    @Override
    public void onFailure(int requestCode, int state, Object result) {
        super.onFailure(requestCode, state, result);
    }
}